package com.ecplatform.common.config;

import com.ecplatform.common.interceptor.UserInfoInterceptor;
import com.ecplatform.common.utils.JwtUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@RequiredArgsConstructor
@Slf4j
public class MVCConfig implements WebMvcConfigurer {

    private final JwtUtil jwtUtil;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.error("--------------------进入WebConfig--------------------");
        registry.addInterceptor(new UserInfoInterceptor(jwtUtil))
                .excludePathPatterns("/api/users/**", "/api/items/page", "/api/items/{id}");
    }
}
